﻿using System.CodeDom.Compiler;
using System.Collections.ObjectModel;

namespace NBuild.Fx.Engine
{
    public sealed class NBuildResults
    {
        private readonly NBuildStatus _status;
        private readonly NBuildCompilerErrorCollection _errors;
        private readonly ProcessingException _processingException;

        internal NBuildResults()
        {
            _status = NBuildStatus.Successful;
        }

        internal NBuildResults(CompilerResults compilerResults)
        {
            _status = NBuildStatus.CompileErrors;
            _errors = new NBuildCompilerErrorCollection(compilerResults);
        }

        internal NBuildResults(ProcessingException processingException)
        {
            _status = NBuildStatus.ProcessingErrors;
            _processingException = processingException;
        }

        public ReadOnlyCollection<NBuildCompilerError> Errors
        {
            get
            {
                return _errors.AsReadOnly();
            }
        }

        public ProcessingException ProcessingException
        {
            get
            {
                return _processingException;
            }
        }

        public NBuildStatus Status
        {
            get
            {
                return _status;
            }
        }
    }

    public enum NBuildStatus
    {
        Successful,
        CompileErrors,
        ProcessingErrors
    }
}
